# -----------------------------------------------------------------------------
# Copyright (c) 2011, MIPS Technologies, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#   * Redistributions of source code must retain the above copyright
#     notice, this list of conditions, and the following disclaimer.
#   * Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions, and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#   * Neither the name of MIPS Technologies, Inc. nor the
#     names of its contributors may be used to endorse or promote products
#     derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MIPS TECHNOLOGIES, INC. BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES, LOSS OF USE, DATA, OR PROFITS, OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
'''
Created on May 17, 2011

@author: rkotler
'''

file_metavar = "<file>"
version_metavar = "<version>"
machine_metavar = "<machine>"
directory_metavar = "<directory>"
standard_metavar = "<standard>"
lib_metavar = "<lib>"
prog_metavar="<prog>"

#
# TBD
# need to handler options which can have space and ones which cannot
# for example:
#  -f dir
#   -fextended-identifiers
#   probably arg, arg2 or something
#   arg2 meaning that there is space between then
#

#
#
# The default model here is that clang reads source and produces .bc
# llvm reads .bc and produces object
# the linker collects .o and adds libraries and produces the executable
#
#

phases = ["clang", "llvm", "assembler", "linker", "all"]

languages = ["c", "c++", "objective-c", "fortran", "ada"]

#
# need to fix issues of code preprocessed or not.
#
default_language_suffix = [
#  ["c",   "c", "i", "h"],
   ["c",   ["c", "i"], "i", "h"],
#  ["c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C" ], "ii", 
   ["c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C", "ii" ], "ii", 
       ["h", "hh", "H", "hp", "hxx", "hpp", "HPP","h++", "tcc"]],
   ["objective-c", "m", "mi", "h"],
   ["objective=c++", ["mm", "M"], "mii", "h"],
#  ["assembler", "sx", ["s", "S"]],
   ["assembler", ["sx", "s", "S"], ["s", "S"], "h"],
   ["linker", ["o", "a"]]                         
]

FileSuffix = (("c", "cc", "cp", "cxx", "cpp", "CPP", "c++", "C"),
              ("i", "ii"),
              ("ll", "bc"),
              ("s", "sx", "S"),
              ("o", "a")
              )

not_implemented = {"not_implemented": ""}

gnu_options = [
    ["--target-help", 
        {"help": "Display target specific command line options"} ],     
     ["--version", 
        {"help": "Display compiler version information"} ],     
    ["--pass-exit-codes", 
        {"help": "Exit with highest error code from a phase"} ],     
    ["--dumpspecs ", 
        {"help": "Display all of the built in spec strings"} ],            
     ["--dumpversion", 
        {"help": "Exit with highest error code from a phase"} ],            
     ["--dumpmachine", 
        {"help": "Display the compiler's target processor"} ],            
     ["--print-search-dirs", 
        {"help": "Display the directories in the compiler's search path"} ],            
     ["--print-libgcc-file-name", 
        {"help": "Display the name of the compiler's companion library"} ], 
     ["--print-file-name",  {"arg": "lib_metavar", 
               "help": "Display the full path to library %arg"}],        
     ["--print-prog-name",  {"arg": "prog_metavar", 
               "help": "Display the full path to compiler component %arg" }],                     
     ["--print-multi-directory",
        {"help": "Display the directory name corresponding to " +
                 "the selected multilib"}],
     ["--print-multi-lib", 
        {"help": "Print the mapping from multilib directory names to " +
                 "compiler switches that enable them"} ],            
     ["--print-sysroot", 
        {"help": "Display the target libraries directory"} ],            
     ["-print-sysroot-headers-suffix", 
        {"help": "Display the sysroot suffix used to find headers"} ],            
     ["-Wa,", 
        {"arg": "<options>",
         
         "help": "assembler <options>"} ],            
    ["-Wl,", 
        {"arg": "<options>",
         
         "help": "linker <options>"} ],            
    ["-Wp,", 
        {"arg": "<options>",
         
         "help": "preprocessor <options>"} ],            
                          
    ["--no-canonical-prefixes", 
        {} ],
    ["-pipe", 
        {} ],
    ["--sysroot",  {"arg": directory_metavar, 
               "help": "Use  {arg} " + 
               " as the root directory for headers and libraries"}],        
        
    ["-B",  {"arg": directory_metavar, 
               "help": "Add  {arg}" +
               " to the compiler's search paths"}],        
    ["-b",  {"arg": machine_metavar, 
               "help": "Run gcc for target {arg} " 
               ", if installed"}],
    ["-V",  {"arg": version_metavar, 
               "help": "Run gcc version number {arg} " +
               ", if installed"}],
    ["-v",  {"help": "Display the programs invoked by the compiler" }],
    ["--###",  {"help": "Like -v but options quoted and commands not executed"}],
    ["-E",  {"help": "Preprocess only; do not compile, assemble or link"}],
    ["-S",  {"help": "Compile only; do not assemble or link"}],          
    ["-c",  {"help": "Compile and assemble, but do not link"}],
    ["-o",  {"arg": file_metavar, 
               "help": "Place the output into {arg}"}],
    ["-x",  {"arg": "<language>", 
            "help": "Specify the language of the following input files" + 
                " Permissible languages include: c c++ assembler none" + 
                " 'none' means revert to the default behavior of" +
                " guessing the language based on the file's extension"}],   
 ]

preprocessor_options = [
    ["-Aquestion=", {"arg": "answer"}], 
    ["-A-question[=", {"arg": "answer"}], 
    ["-C"],
    ["-XdD"],
    ["-XdI"],  
    ["-dD"],
    ["-dM"],
    ["-XdN"], 
    ["-D", {"arg": "macro[=defn]"}],
    ["-E"],
    ["-H"],
    ["-idirafter", {"arg": "dir"}], 
    ["-include", {"arg":  "file"}],
    ["-imacros", {"arg": "file"}], 
    ["-iprefix", {"arg": "file"}],
    ["-iwithprefix", {"arg": "dir"}], 
    ["-iwithprefixbefore", {"arg": "dir"}],
    ["-isystem", {"arg": "dir"}], 
    ["-imultilib", {"arg": "dir"}],
    ["-isysroot",  {"arg": "dir"}], 
    ["-M"],
    ["-MM"],
    ["-MF"],
    ["-MG"],
    ["-MP"],
    ["-MQ"],
    ["-MT"],
    ["-nostdinc"],
    ["-P"],
#    ["-f", {"arg": "working-directory"}],
    ["-remap"], 
    ["-trigraphs"],
    ["-undef"],
    ["-Umacro"],
    ["-Wp,", {"arg": "option"}], 
    ["-Xpreprocessor", {"arg": "option"}],                        


]

gcc_c_options = [
    ["-ansi" ],
    ["-std=", {"arg": "standard"}],
    ["-fgnu89-inline"],
    ["-aux-info",  {"arg":"filename"}],
    ["-fno-asm"],
    ["-fno-builtin"],
    ["-fno-builtin-function"],
    ["-fhosted"],
    ["-ffreestanding"],
    ["-fopenmp"],
    ["-fms-extensions"],
    ["-fplan9-extensions10"],
    ["-trigraphs"],
    ["-no-integrated-cpp"],
    ["-traditional"],
    ["-traditional-cpp"],
    ["-fallow-single-precision"],
    ["-fcond-mismatch"],
    ["-flax-vector-conversions"],
    ["-fsigned-bitfields"],
    ["-fsigned-char"],
    ["-funsigned-bitfields"],
    ["-funsigned-char"]                                  
]

gcc_common_options = [
  ["--target-help", {"help":"Alias for --help=target"}],
  ["--version"],                   
  ["-G", {"arg": "<number>", "help": "Put global and static data smaller than <number>" +
                              "bytes into a special section (on some targets)" }],
 # ["-O", {"arg": "<number>", "help": "Set optimization level to <number>"}],
  ["-O"],
  ["-O0"],
  ["-O1"],
  ["-O2"],
  ["-O3"],    
  ["-Os", {"help": "Optimize for space rather than speed"}],
#  ["-W", {"help": "This switch is deprecated; use -Wextra instead"}],
  ["-Waggregate-return", {"help": "Warn about returning structures, unions or arrays"}],
  ["-Warray-bounds", {"help":  "Warn if an array is accessed out of bounds"}],
  ["-Wattributes", {"help": "Warn about inappropriate attribute usage"}],
  ["-Wcast-align", {"help":  "Warn about pointer casts which increase alignment"}],
  ["-Wcoverage-mismatch", {"help": "Warn instead of error in case profiles in" +
                              "-fprofile-use do not match" }],
  ["-Wdeprecated-declarations",   {"help": "Warn about uses of __attribute__((deprecated)) declarations"}],
  ["-Wdisabled-optimization", {"help":  "Warn when an optimization pass is disabled"}],
  ["-Werror", {"help": "Treat all warnings as errors"}],
  ["-Werror=", {"arg": "<error>", "help": "Treat specified warning as error"}],
  ["-Wextra", {"help": "Print extra (possibly unwanted) warnings"}],
  ["-Wfatal-errors", {"help": "Exit on the first error occurred"}],
  ["-Wframe-larger-than=", {"arg": "<number>", 
                            "help":  "-Wframe-larger-than=<number> Warn if a function's " +
                              "stack frame requires more than <number> bytes "}],
  ["-Winline", {"help": "Warn when an inlined function cannot be inlined"}],
  ["-Wlarger-than=", {"arg": "<number>", "help":  "Warn if an object is larger than <number> bytes"}],
  ["-Wlogical-op", {"help": "Warn when a logical operator is suspicously" +
                              " always evaluating to true or false" }],
  ["-Wmissing-noreturn", {"help": "Warn about functions which might be candidates " +
                              "for __attribute__((noreturn))"}],
  ["-Wmudflap", {"help": "Warn about constructs not instrumented by -fmudflap"}],
  ["-Woverflow", {"help": "Warn about overflow in arithmetic expressions"}],
  ["-Wpacked", {"help":  "Warn when the packed attribute has no effect on struct layout"}],
  ["-Wpadded", {"help": "Warn when padding is required to align structure members"}],
  ["-Wshadow", {"help": "Warn when one local variable shadows another"}],
  ["-Wstack-protector", {"help": "Warn when not issuing stack smashing protection for some reason"}],
  ["-Wstring-overflow", {"help": "Warn about code which might break strict aliasing rules"}],
#  ["-Wstrict-aliasing", {"help": "Warn about code which might break strict aliasing rules"}],                            rules
  ["-Wstrict-overflow", {"help": "Warn about optimizations that assume that signed " + 
                         "overflow is undefined" }],
  ["-Wstrict-overflow=", {"help": "Warn about optimizations that assume that signed " + 
                              "overflow is undefined"}],
  ["-Wswitch", {"help": "Warn about enumerated switches, with no default, missing a case"}],
  ["-Wswitch-default", {"help": "Warn about enumerated switches missing a " + 
                              "'default:' statement"}],
  ["-Wswitch-enum", {"help": "Warn about all enumerated switches missing a " +
                              "specific case"}],
  ["-Wsystem-headers", {"help": "Do not suppress warnings from system headers"}],
  ["-Wtype-limits", {"help": "Warn if a comparison is always true or always "+
                              "false due to the limited range of the data type"}],
  ["-Wuninitialized", {"help": "Warn about uninitialized automatic variables"}],
  ["-Wunreachable-code", {"help": "Warn about code that will never be executed"}],
  ["-Wunsafe-loop-optimizations",  {"help": " Warn if the loop cannot be optimized due to" +
                              " nontrivial assumptions."}],
  ["-Wunused", {"help": "Enable all -Wunused- warnings"}],
  ["-Wunused-function", {"help": "Warn when a function is unused"}],
  ["-Wunused-label", {"help": "Warn when a label is unused"}],
  ["-Wunused-parameter", {"help": "Warn when a function parameter is unused"}],
  ["-Wunused-value", {"help": "Warn when an expression value is unused"}],
  ["-Wunused-variable", {"help": "Warn when a variable is unused"}],
  ["-aux-info" , {"arg": "<file>", "help": "Emit declaration information into <file>"}],                 
  ["-auxbase"],                  
  ["-auxbase-strip"],              
  ["-d<letters>", {"arg": "<letters>" , "help": "Enable dumps from specific passes of the compiler"}],
  ["-dumpbase", {"arg": "<file>", "help": "Set the file basename to be used for dumps"}],
  ["-fPIC", {"help": "Generate position-independent code if possible (large mode)"}],
  ["-fPIE", {"help": "Generate position-independent code for executables if possible (large mode)"}],
  ["-fabi-version=", {"arg": "<version>"}],             
  ["-falign-functions", {"help":"Align the start of functions}"}],
  ["-falign-functions="],          
  ["-falign-jumps", {"help": "Align labels which are only reached by jumping"}],
  ["-falign-jumps="],           
  ["-falign-labels", {"help": "Align all labels"}],
  ["-falign-labels="],             
  ["-falign-loops",  {"help": "Align the start of loops"}],
  ["-falign-loops=" ],              
  ["-fargument-alias", {"help":  "Specify that arguments may alias each other and globals"}],
  ["-fargument-noalias", {"help": "Assume arguments may alias globals but not each other"}],
  ["-fargument-noalias-anything", {"help": "Assume arguments alias no other storage"}],
  ["-fargument-noalias-global", {"help": "Assume arguments alias neither each other nor globals"}],
  ["-fassociative-math", {"help": "Allow optimization for floating-point arithmetic " +
                              "which may change the result of the operation due to rounding."}],
  ["-fasynchronous-unwind-tables", {"help": "Generate unwind tables that are exact at "
              + "each  instruction boundary "}],
  ["-fauto-inc-dec", {"help": "Generate auto-inc/dec instructions"}],
  ["-fbounds-check", {"help": "Generate code to check bounds before indexing arrays"}],
  ["-fbranch-count-reg", {"help": "Replace add, compare, branch with branch on count register"}],
  ["-fbranch-probabilities", {"help": "Use profiling information for branch probabilities"}],
  ["-fbranch-target-load-optimize", {"help":  "Perform branch target load optimization before " +
                              "prologue / epilogue threading"}],
  ["-fbranch-target-load-optimize2", {"help": "Perform branch target load optimization after "+
                              "prologue / epilogue threading"}],
  ["-fbtr-bb-exclusive", {"help": "Restrict target load migration not to re-use " +
                              "registers in any basic block"}],
  ["-fcall-saved-<register>", {"help": "Mark <register> as being preserved across functions"}],
  ["-fcall-used-<register>", {"help": "Mark <register> as being corrupted by function calls"}],
  ["-fcaller-saves", {"help": "Save registers around function calls"}],
  ["-fcheck-data-deps", {"help": "Compare the results of several data dependence  analyzers."}],
  ["-fcommon", {"help": "Do not put uninitialized globals in the common section"}],
  ["-fconserve-stack", {"help": "Do not perform optimizations increasing noticeably stack usage"}],
  ["-fcprop-registers", {"help": "Perform a register copy-propagation optimization pass"}],
  ["-fcrossjumping", {"help": "Perform cross-jumping optimization"}],
  ["-fcse-follow-jumps", {"help": "When running CSE, follow jumps to their targets"}],
  ["-fcse-skip-blocks", {"help": "When running CSE, follow conditional jumps"}],
  ["-fcx-fortran-rules", {"help": "Complex multiplication and division follow Fortran rules"}],
  ["-fcx-limited-range", {"help": "Omit range reduction step when performing complex division"}],
  ["-fdata-sections", {"help": "Place data items into their own section"}],
  ["-fdbg-cnt-list", {"help": "List all available debugging counters with their limits and counts."}],
  ["-fdbg-cnt=",  {"arg": "-fdbg-", "help": "cnt=<counter>:<limit>[,<counter>:<limit>,..." +    
                              "Set the debug counter limit."}],   
  ["-fdce", {"help":  "Use the RTL dead code elimination pass"}],
  ["-fdebug-prefix-map=", {"help": "Map one directory name to another in debug information"}],
  ["-fdefer-pop", {"help": "Defer popping functions args from stack until later"}],
  ["-fdelayed-branch", {"help": "Attempt to fill delay slots of branch instructions"}],
  ["-Xfdelete-null-pointer-checks", {"help": "Delete useless null pointer checks"}],
  ["-fdiagnostics-show-location=", {"help": "[once|every-line] How often to emit source " +
                              "location at the beginning of line-wrapped diagnostics"}],
  ["-fdiagnostics-show-option", {"help": "Amend appropriate diagnostic messages with the " +
                              "command line option that controls them"}],
  ["-fdse", {"help": "Use the RTL dead store elimination pass"}],
  ["-fdump-<type>", {"help": "Dump various compiler internals to a file"}],
  ["-Xfdump-noaddr", {"help": "Suppress output of addresses in debugging dumps"}],
  ["-fdump-unnumbered", {"help": "Suppress output of instruction numbers, line " + 
                              "number notes and addresses in debugging dumps"}],
  ["-fdwarf2-cfi-asm", {"help": "Enable CFI tables via GAS assembler directives."}],
  ["-fearly-inlining", {"help": "Perform early inlining"}],
  ["-Xfeliminate-dwarf2-dups", {"help": "Perform DWARF2 duplicate elimination"}],
  ["-feliminate-unused-debug-symbols", {"help": "Perform unused type elimination in debug info"}],
  ["-feliminate-unused-debug-types", {"help": "Perform unused type elimination in debug info"}],
  ["-femit-class-debug-always", {"help":  "Do not suppress C++ class debug information."}],
  ["-fexceptions", {"help": "Enable exception handling"}],
  ["-fexpensive-optimizations", {"help": "Perform a number of minor, expensive optimizations"}],
  ["-ffast-math", {}],                 
  ["-ffinite-math-only", {"help": "Assume no NaNs or infinities are generated"}],
  ["-ffixed-<register>", {"help": "Mark <register> as being unavailable to the compiler"}],
  ["-Xffloat-store", {"help": "Don't allocate floats and doubles in extended-precision registers"}],
  ["-fforce-addr", {"help": "Does nothing.  Preserved for backward compatibility."}],
  ["-fforward-propagate", {"help": "Perform a forward propagation pass on RTL"}],
  ["-ffunction-cse", {"help": "Allow function addresses to be held in registers"}],
  ["-ffunction-sections", {"help": "Place each function into its own section"}],
  ["-Xfgcse", {"help": "Perform global common subexpression elimination"}],
  ["-Xfgcse-after-reload", {"help": "Perform global common subexpression elimination " +
                              "after register allocation has finished"}],
  ["-fgcse-las", {"help": "Perform redundant load after store elimination in " + 
                              "global common subexpression elimination"}],
  ["-fgcse-lm", {"help": "Perform enhanced load motion during global common " + 
                              "subexpression elimination"}],
  ["-Xfgcse-sm", {"help": "Perform store motion after global common subexpression elimination"}],
  ["-fgraphite", {"help": "Enable in and out of Graphite representation"}],
  ["-fgraphite-identity", {"help": "Enable Graphite Identity transformation"}],
  ["-Xfguess-branch-probability", {"help": "Enable guessing of branch probabilities"}],
  ["-fhelp", {}],                      
  ["-fhelp=", {}],                     
  ["-fident", {"help": "Process #ident directives"}],
  ["-fif-conversion", {"help": "Perform conversion of conditional jumps to branchless equivalents"}],
  ["-fif-conversion2", {"help": "Perform conversion of conditional jumps to conditional execution"}],
  ["-findirect-inlining", {"help": "Perform indirect inlining"}],
  ["-finhibit-size-directive", {"help": "Do not generate .size directives"}],
  ["-Xfinline", {"help": 'Pay attention to the "inline" keyword'}],
  ["-finline-functions", {"help": "Integrate simple functions into their callers"}],
  ["-finline-functions-called-once", {"help": "Integrate functions called once into their callers"}],
  ["-finline-limit-", {}],             
  ["-finline-limit=", {"arg": "<number>", "help": "Limit the size of inlined functions to <number>"}],
  ["-finline-small-functions", {"help": "Integrate simple functions into their callers " +
                                " when code size is known to not growth"}],
  ["-Xfinstrument-functions", {"help": "Instrument function entry and exit with profiling calls"}],
  ["-finstrument-functions-exclude-file-list=", {"arg": "<filelist>",
          "help": "-finstrument-functions-exclude-file-list=filename,... " +
          "Do not instrument functions listed in files"}],

  ["-fpic", {"help" : "Generate position-independent code if possible  (small mode)"}],
  ["-fpie", {"help" : "Generate position-independent code for executables if possible (small mode)"}],

  ["-g", {"help": "Generate debug information in default format"}],
  ["-gcoff", {"help": "Generate debug information in COFF format"}],
  ["-gdwarf-2", {"help": "Generate debug information in DWARF v2 format"}],
  ["-ggdb", {"help": "Generate debug information in default extended format"}],
  ["gstabs", {"help": "Generate debug information in STABS format"}],
  ["-gstabs+", {"help": "Generate debug information in extended STABS format"}],
  ["-gvms", {"help": "Generate debug information in VMS format"}],
  ["-gxcoff", {"help": "Generate debug information in XCOFF format"}],
  ["-gxcoff+", {"help": "Generate debug information in extended XCOFF format"}],
  ["-o", {"arg": "<file>", "help":"Place output into <file>"}],
   
  ["-Xp", {"help": "Enable function profiling"}],
  ["-pedantic", {"help": "Issue warnings needed for strict compliance to the standard"}],
  ["-pedantic-errors", {"help": "Like -pedantic but issue them as errors"}],
  ["-pie", {"help": "Create a position independent executable"}],
  ["-quiet", {"help": "Do not display functions compiled or elapsed time"}],
  ["-shared", {"help": "Create a shared library"}],
  ["-v", {"help": "Enable verbose output"}],
  ["-version", {"help": "Display the compiler's version"}],
  ["-w", {"help": "Suppress warnings"}],
#  ["-finstrument-functions-exclude-function-list= -finstrument-functions-exclude-
#                             function-list=name,...  Do not instrument listed
#                              functions
  ["-Xfipa-cp", {"help": "Perform Interprocedural constant propagation"}],
  ["-Xfipa-cp-clone", {"help": "Perform cloning to make Interprocedural constant propagation stronger"}],
  ["-Xfipa-matrix-reorg", {"help": "Perform matrix layout flattening and " +
                           "transposing based on profiling information."}],
  ["-fipa-pta", {"help": "Perform interprocedural points-to analysis"}],
  ["-fipa-pure-const", {"help": "Discover pure and const functions"}],
  ["-fipa-reference", {"help": "Discover readonly and non addressable static variables"}],
  ["-fipa-struct-reorg", {"help": "Perform structure layout optimizations based on profiling information."}],                   
  ["-Xfipa-type-escape", {"help": "Type based escape and alias analysis"}],
  ["-fira-algorithm=",  {"arg":"<CB|Prioriry>", "help": "-fira-algorithm=[CB|priority] Set the used IRA algorithm"}],
  ["-fira-coalesce", {"help": "Do optimistic coalescing"}],
  ["-fira-region=", {"arg": "<one|all|mixed>", "help": "-fira-region=[one|all|mixed] Set regions for IRA"}],
  ["-fira-share-save-slots", {"help": "Share slots for saving different hard registers."}],
  ["-fira-share-spill-slots", {"help": "Share stack slots for spilled pseudo-registers."}],
  ["-fira-verbose=", {"arg": "<number>", 
                      "help":  "-fira-verbose=<number> Control IRA's level of diagnostic messages."}],
  ["-fivopts", {"help": "Optimize induction variables on trees"}],
  ["-fjump-tables", {"help": "Use jump tables for sufficiently large switch statements"}],
  ["-fkeep-inline-functions", {"help": "Generate code for functions even if they are fully inlined"}],
  ["-fkeep-static-consts", {"help": "Emit static const variables even if they are not used"}],
  ["-Xfleading-underscore", {"help": "Give external symbols a leading underscore"}],
  ["-floop-block", {"help": "Enable Loop Blocking transformation"}],
  ["-floop-interchange", {"help": "Enable Loop Interchange transformation"}],
  ["-floop-optimize", {"help": "Does nothing.  Preserved for backward compatibility."}],                              
  ["-floop-strip-mine", {"help": "Enable Loop Strip Mining transformation"}],
  ["-fmath-errno", {"help": "set errno after built-in math functions"}],
  ["-fmem-report", {"help": "Report on permanent memory allocation"}],
  ["-fmerge-all-constants", {"help": "Attempt to merge identical constants and constant variables"}],
  ["-fmerge-constants", {"help": "Attempt to merge identical constants across compilation units"}],                         
  ["-fmerge-debug-strings", {"help": "Attempt to merge identical debug strings across compilation units"}],
  ["-fmessage-length=", {"arg": "<number>", "help": "Limit diagnostics to <number> characters per " +
                              "line.  0 suppresses line-wrapping"}],
  ["-Xfmodulo-sched", {"help": "Perform SMS based modulo scheduling before the first scheduling pass"}],
  ["-Xfmodulo-sched-allow-regmoves", {"help":  "Perform SMS based modulo scheduling with " +
                              "register moves allowed"}],
  ["-Xfmove-loop-invariants", {"help": "Move loop invariant computations out of loops"}],
  ["-fmudflap", {"help": "Add mudflap bounds-checking instrumentation for single-threaded program"}],
  ["-fmudflapir", {"help": "Ignore read operations when inserting mudflap instrumentation"}],                            
  ["-fmudflapth", {"help": "Add mudflap bounds-checking instrumentation for multi-threaded program"}],
  ["-Xfnon-call-exceptions", {"help": "Support synchronous non-call exceptions"}],
  ["-Xfomit-frame-pointer", {"help": "When possible do not generate stack frames"}],
  ["-foptimize-register-move", {"help": "Do the full register move optimization pass"}],
  ["-Xfoptimize-sibling-calls", {"help": "Optimize sibling and tail recursive calls"}],
  ["-Xfpack-struct", {"help": "Pack structure members together without holes"}],
  ["-Xfpack-struct=", {"arg": "<number>", "help": "Set initial maximum structure member alignment"}],
  ["-fpcc-struct-return", {"help": "Return small aggregates in memory, not registers"}],
  ["-Xfpeel-loops", {"help": "Perform loop peeling"}],
  ["-fpeephole", {"help": "Enable machine specific peephole optimizations"}],
  ["-fpeephole2", {"help": "Enable an RTL peephole pass before sched2"}],
  ["-fpic", {"help": "Generate position-independent code if possible  (small mode)"}],
  ["-fpie", {"help": "Generate position-independent code for executables if possible (small mode)"}],
  ["-fplugin-arg-", {"arg": "<name>-<key>[=<value>]", "help":  "Specify argument <key>=<value> for plugin <name>"}],                           
  ["-fplugin=", {"help": "Specify a plugin to load"}],
  ["-fpost-ipa-mem-report", {"help": "Report on memory allocation before interprocedural optimization"}],
  ["-fpre-ipa-mem-report", {"help": "Report on memory allocation before interprocedural optimization"}],
  ["-Xfpredictive-commoning", {"help": "Run predictive commoning optimization."}],
  ["-Xfprefetch-loop-arrays", {"help": "Generate prefetch instructions, if available, for arrays in loops"}],
  ["-fprofile", {"help": "Enable basic program profiling code"}],
  ["-fprofile-arcs", {"help": "Insert arc-based program profiling code"}],
  ["-fprofile-correction", {"help": "Enable correction of flow inconsistent profile data input"}],
  ["-Xfprofile-dir=", {"arg": "<dir>", "help": "Set the top-level directory for storing the " +
                              "profile data. The default is 'pwd'."}],
  ["-Xfprofile-generate", {"help": "Enable common options for generating profile info " +
                              "for profile feedback directed optimizations"}],
  ["-Xfprofile-generate=", {"arg": "<opt>", "help": "Enable common options for generating profile info " +
                              "for profile feedback directed optimizations, and " +
                              "set -fprofile-dir="}],
  ["-Xfprofile-use", {"help":   "Enable common options for performing profile " +
                              "feedback directed optimizations"}],
  ["-Xfprofile-use=", {"help": "Enable common options for performing profile " +
                              "feedback directed optimizations, and set " +
                              "-fprofile-dir="}],
  ["-fprofile-values", {"help": "Insert code to profile values of expressions"}],
  ["-frandom-seed"],               
  ["-frandom-seed=", {"arg": "<string>", "help": "Make compile reproducible using <string> " }],
  ["-freciprocal-math", {"help": "Same as -fassociative-math for expressions which " +
                              "include division."}],
  ["-frecord-gcc-switches", {"help": "Record gcc command line switches in the object file."}],
  ["-freg-struct-return", {"help": "Return small aggregates in registers"}],
  ["-fregmove", {"help": "Enables a register move optimization"}],
  ["-Xfrename-registers", {"help": "Perform a register renaming optimization pass"}],
  ["-Xfreorder-blocks", {"help": "Reorder basic blocks to improve code placement"}],
  ["-Xfreorder-blocks-and-partition", {"help": "Reorder basic blocks and partition into hot " +
                              "and cold sections"}],
  ["-freorder-functions", {"help": "Reorder functions to improve code placement"}],
  ["-frerun-cse-after-loop", {"help": "Add a common subexpression elimination pass after " +
                              "loop optimizations"}],
  ["-frerun-loop-opt", {"help": "Does nothing.  Preserved for backward compatibility."}],                       
  ["-freschedule-modulo-scheduled-loops", {"help":  "Enable/Disable the traditional scheduling " +
                              "in loops that already passed modulo scheduling"}],
  ["-Xfrounding-math", {"help": "Disable optimizations that assume default FP " +
                              "rounding behavior"}],
  ["-frtl-abstract-sequences", {"help":   "Perform sequence abstraction optimization on RTL"}],                                
  ["-fsched-interblock", {"help": "Enable scheduling across basic blocks"}],
  ["-fsched-spec", {"help": "Allow speculative motion of non-loads"}],
  ["-fsched-spec-load", {"help": "Allow speculative motion of some loads"}],                         
  ["-fsched-spec-load-dangerous", {"help": "Allow speculative motion of more loads"}],
  ["-Xfsched-stalled-insns", {"help": "Allow premature scheduling of queued insns"}],
  ["-fsched-stalled-insns-dep", {"help": "Set dependence distance checking in premature " +
                              "scheduling of queued insns"}],
  ["-fsched-stalled-insns-dep=", {"arg":"<number>", "help": "Set dependence distance checking in " +
                              "premature scheduling of queued insns"}],
  ["-fsched-stalled-insns=", {"arg":"<number>", "help":"Set number of queued insns that can be " +
                              "prematurely scheduled"}],
  ["-fsched-verbose=", {"arg":"<number>", "help":"Set the verbosity level of the scheduler"}],                        
  ["-Xfsched2-use-superblocks", {"help": "If scheduling post reload, do superblock scheduling"}],
  ["-Xfsched2-use-traces", {"help": "If scheduling post reload, do trace scheduling"}],
  ["-fschedule-insns", {"help": "Reschedule instructions before register allocation"}],
  ["-fschedule-insns2", {"help": "Reschedule instructions after register allocation"}],
  ["-fsection-anchors", {"help": "Access data in the same section from shared anchor points"}],                           
  ["-Xfsee", {"help": "Eliminate redundant sign extensions using LCM."}],
  ["-fsel-sched-pipelining", {"help": "Perform software pipelining of inner loops during selective scheduling"}],
  ["-fsel-sched-pipelining-outer-loops", {"help": "Perform software pipelining of outer loops " +
                              "during selective scheduling"}],
  ["-fsel-sched-reschedule-pipelined", {"help": "Reschedule pipelined regions without pipelining"}],                              
  ["-fselective-scheduling", {"help": "Schedule instructions using selective scheduling algorithm"}],                           
  ["-fselective-scheduling2", {"help": "Run selective scheduling after reload"}],
  ["-fshow-column", {"help": "Show column numbers in diagnostics, when available.  Default off"}],                              
  ["-Xfsignaling-nans", {"help": "Disable optimizations observable by IEEE signaling NaNs"}],                            
  ["-fsigned-zeros", {"help": "Disable floating point optimizations that ignore the IEEE signedness of zero"}],
  ["-Xfsingle-precision-constant", {"help": "Convert floating point constants to single precision constants"}],
  ["-fsplit-ivs-in-unroller", {"help": "Split lifetimes of induction variables when loops are unrolled"}],  
  ["-Xfsplit-wide-types", {"help": "Split wide types into independent registers"}],
  ["-fstack-check", {"help": "Insert stack checking code into the program. " +  
                              "Same as -fstack-check=specific"}],
  ["-fstack-check=", {"arg": "<no|generic|specific>",
                      "help": "[no|generic|specific] Insert stack checking code into the program"}],
  ["-fstack-limit"],               
  ["-fstack-limit-register=", {"arg":"<register>", "help":"Trap if the stack goes past <register>"}],
  ["-fstack-limit-symbol=", {"help": "<name> Trap if the stack goes past symbol <name>"}],
  ["-fstack-protector", {"help": "Use propolice as a stack protection method"}],
  ["-fstack-protector-all", {"help": "Use a stack protection method for every function"}],
  ["-fstrength-reduce", {"help": "Does nothing.  Preserved for backward  compatibility."}],
  ["-fstrict-aliasing", {"help": "Assume strict aliasing rules apply"}],
  ["-fstrict-overflow", {"help": "Treat signed overflow as undefined"}],
  ["-fsyntax-only", {"help":  "Check for syntax errors, then stop"}],
  ["-ftarget-help"],               
  ["-ftest-coverage", {"help": "Create data files needed by gcov"}],
  ["-fthread-jumps", {"help": "Perform jump threading optimizations"}],
  ["-ftime-report", {"help": "Report the time taken by each compiler pass"}],
  ["-Xftls-model=", {"arg": "[global-dynamic|local-dynamic|initial-exec|local-exec]",
                    "help":  "Set the default thread-local storage code generation model"}],                              
  ["-ftoplevel-reorder", {"help": "Reorder top level functions, variables, and asms"}],
  ["-Xftracer", {"help": "Perform superblock formation via tail duplication"}],
  ["-Xftrapping-math", {"help": "Assume floating-point operations can trap"}],
  ["-ftrapv", {"help": "Trap for signed overflow in addition, subtraction and multiplication"}],                            
  ["-ftree-builtin-call-dce", {"help": "Enable conditional dead code elimination for builtin calls"}],                              
  ["-ftree-ccp", {"help": "Enable SSA-CCP optimization on trees"}],
  ["-ftree-ch", {"help": "Enable loop header copying on trees"}],
  ["-ftree-copy-prop", {"help": "Enable copy propagation on trees"}],
  ["-ftree-copyrename", {"help": "Replace SSA temporaries with better names in copies"}],
  ["-Xftree-cselim", {"help": "Transform condition stores into unconditional ones"}],
  ["-Xftree-dce", {"help": "Enable SSA dead code elimination optimization on trees"}],
  ["-Xftree-dominator-opts", {"help": "Enable dominator optimizations"}],
  ["-ftree-dse", {"help": "Enable dead store elimination"}],
  ["-ftree-fre", {"help": "Enable Full Redundancy Elimination (FRE) on trees"}],
  ["-ftree-loop-distribution", {"help": "Enable loop distribution on trees"}],
  ["-ftree-loop-im", {"help": "Enable loop invariant motion on trees"}],
  ["-ftree-loop-ivcanon", {"help": "Create canonical induction variables in loops"}],
  ["-ftree-loop-linear", {"help": "Enable linear loop transforms on trees"}],
  ["-ftree-loop-optimize", {"help": "Enable loop optimizations on tree level"}],
  ["-ftree-lrs", {"help": "Perform live range splitting during the SSA->normal pass"}],
  ["-Xftree-parallelize-loops", {"help": "=   Enable automatic parallelization of loops"}],
  ["-Xftree-pre", {"help": "Enable SSA-PRE optimization on trees"}],
  ["-ftree-reassoc", {"help": "Enable reassociation on tree level"}],
  ["-ftree-salias", {"help": "Does nothing.  Preserved for backward compatibility."}],
  ["-ftree-scev-cprop", {"help": "Enable copy propagation of scalar-evolution information."}],                             
  ["-ftree-sink", {"help": "Enable SSA code sinking on trees"}],
  ["-ftree-sra", {"help": "Perform scalar replacement of aggregates"}],
  ["-ftree-store-ccp", {"help": "Does nothing.  Preserved for backward compatibility."}],                              
  ["-ftree-store-copy-prop", {"help": "Does nothing.  Preserved for backward compatibility."}],                              
  ["-ftree-switch-conversion", {"help": "Perform conversions of switch initializations."}],
  ["-ftree-ter", {"help": "Replace temporary expressions in the SSA->normal pass"}],                              
  ["-ftree-vect-loop-version", {"help": "Enable loop versioning when doing loop vectorization on trees"}],
  ["-Xftree-vectorize", {"help": "Enable loop vectorization on trees"}],
  ["-ftree-vectorizer-verbose=", {"arg": "<number>", "help": "Set the verbosity level of the vectorizer"}],
  ["-Xftree-vrp", {"help": "Perform Value Range Propagation on trees"}],
  ["-funit-at-a-time", {"help": "Compile whole compilation unit at a time"}],
  ["-Xfunroll-all-loops", {"help": "Perform loop unrolling for all loops"}],
  ["-Xfunroll-loops", {"help": "Perform loop unrolling when iteration count is known"}],                              
  ["-Xfunsafe-loop-optimizations", {"help": "Allow loop optimizations to assume that " +
                                   "the loops behave in normal way"}],                              
  ["-Xfunsafe-math-optimizations", {"help": "Allow math optimizations that may violate IEEE or ISO standards"}],                              
  ["-Xfunswitch-loops", {"help": "Perform loop unswitching"}],
  ["-funwind-tables", {"help": "Just generate unwind tables for exception handling"}],
  ["-fuse-ld="],                   
  ["-fvar-tracking", {"help": "Perform variable tracking"}],
  ["-fvar-tracking-uninit", {"help": "Perform variable tracking and also tag variables " +
                              "that are uninitialized"}],
  ["-Xfvariable-expansion-in-unroller", {"help": "Apply variable expansion when loops are unrolled"}],                              
  ["-fvect-cost-model", {"help": "Enable use of cost model in vectorization"}],
  ["-fverbose-asm", {"help": "Add extra commentary to assembler output"}],
  ["-fversion"],                   
  ["-fvisibility=", {"arg": "[default|internal|hidden|protected]", 
                     "help": "Set the default symbol visibility"}],
  ["-fvpt", {"help": "Use expression value profiles in optimizations"}],
  ["-fweb", {"help": "Construct webs and split unrelated uses of single variable"}],                              
  ["-Xfwhole-program", {"help": "Perform whole program optimizations"}],
  ["-fwrapv", {"help": "Assume signed arithmetic overflow wraps around"}],
  ["-fzero-initialized-in-bss", {"help": "Put zero initialized data in the bss section"}],
  ["-static", {"help": "Prevents linking with the shared libraries."}]
]

directory_options = [
 ["-B", {"arg": "prefix"}],
 ["-I", {"arg": "dir"}],
 ["-iplugindir=", {"arg": "dir"}],
 ["-iquotedir"],
 ["-L", {"arg": "dir"}],
 ["-specs=", {"arg": "file"}],
 ["-I-"], 
 ["-" + "-sysroot=", {"arg": "dir"}]
]

linking_options = [
   ["-l", {"arg": "library"}], 
   ["-nostartfiles"],
   ["-nodefaultlibs"],
   ["-nostdlib"],
   ["-pie"],
   ["-rdynamic"], 
#   ["-s"],  
   ["--rtti"],  
   ["-static"],  
   ["-static-libgcc"],
   ["-static-libstdc++"],
   ["-shared"],  
   ["-shared-libgcc"],
   ["-symbolic"], 
   ["-T", {"arg": "script"}],
   ["-Wl,", {"arg": "option"}],
   ["-Xlinker", {"arg": "option"}], 
   ["-u", {"arg": "symbol"}]            
]

llvm_options = [ ["-emit-obj"],  ["-direct"], ["-emit-llvm"] ]

mips_options = [
   ["-EL"],
   ["-EB"],
   ["-march=", {"arg": "arch"}],
   ["-mtune=", {"arg": "arch"}], 
   ["-mips1"],
   ["-mips2"],
   ["-mips3"],
   ["-mips4"],
   ["-mips32"],
   ["-mips32r2"], 
   ["-mips64"],
   ["-mips64r2"], 
   ["-mips16"],
   ["-mno-mips16"],
   ["-mflip-mips16"], 
   ["-minterlink-mips16"],
   ["-mno-interlink-mips16"], 
   ["-mabi=", {"arg": "abi"}],
   ["-mabicalls"],
   ["-mno-abicalls"],
   ["-mshared"],
   ["-mno-shared"],
   ["-mplt"],
   ["-mno-plt"],
   ["-mxgot"],
   ["-mno-xgot"], 
   ["-mgp32"],
   ["-mgp64"],
   ["-mfp32"],
   ["-mfp64"],
   ["-mhard-float"],
   ["-msoft-float"], 
   ["-msingle-float"],
   ["-mdouble-float"],
   ["-mdsp"],
   ["-mno-dsp"],
   ["-mdspr2"],
   ["-mno-dspr2"], 
   ["-mfpu=", {"arg": "fpu-type"}], 
   ["-msmartmips"],
   ["-mno-smartmips"], 
   ["-mpaired-single"],
   ["-mno-paired-single"],
   ["-mdmx"],
   ["-mno-mdmx"], 
   ["-mips3d"],
   ["-mno-mips3d"],
   ["-mmt"],
   ["-mno-mt"],
   ["-mllsc"],
   ["-mno-llsc"], 
   ["-mlong64"],
   ["-mlong32"],
   ["-msym32"],
   ["-mno-sym32"], 
   ["-Gnum"],
   ["-mlocal-sdata"],
   ["-mno-local-sdata"], 
   ["-mextern-sdata"],
   ["-mno-extern-sdata"],
   ["-mgpopt"],
   ["-mno-gopt"], 
   ["-membedded-data"],
   ["-mno-embedded-data"], 
   ["-muninit-const-in-rodata"],
   ["-mno-uninit-const-in-rodata"],
   ["-mcode-readable=", {"arg": "setting"}], 
   ["-msplit-addresses"],
   ["-mno-split-addresses"], 
   ["-mexplicit-relocs"],
   ["-mno-explicit-relocs"], 
   ["-mcheck-zero-division"],
   ["-mno-check-zero-division"], 
   ["-mdivide-traps"],
   ["-mdivide-breaks"], 
   ["-mmemcpy"],
   ["-mno-memcpy"],
   ["-mlong-calls"],
   ["-mno-long-calls"], 
   ["-mmad"],
   ["-mno-mad"],
   ["-mfused-madd"],
   ["-mno-fused-madd"],
   ["-nocpp"], 
   ["-mfix-r4000"],
   ["-mno-fix-r4000"],
   ["-mfix-r4400"],
   ["-mno-fix-r4400"], 
   ["-mfix-r10000"],
   ["-mno-fix-r10000"],
   ["-mfix-vr4120"],
   ["-mno-fix-vr4120"], 
   ["-mfix-vr4130"],
   ["-mno-fix-vr4130"],
   ["-mfix-sb1"],
   ["-mno-fix-sb1"], 
   ["-mflush-func=", {"arg": "func"}],
   ["-mno-flush-func"], 
   ["-mbranch-cost=", {"arg": "num"}],
   ["-mbranch-likely"],
   ["-mno-branch-likely"], 
   ["-mfp-exceptions"],
   ["-mno-fp-exceptions"], 
   ["-mvr4130-align"],
   ["-mno-vr4130-align"],
   ["-msynci"],
   ["-mno-synci"], 
   ["-mrelax-pic-calls"],
   ["-mno-relax-pic-calls"],
   ["-mmcount-ra-address"],
   ["-mips-fix-global-base-reg=", {"arg": "bool"}], 
   ["-enable-mips-delay-filler=", {"arg": "bool"}] 
                
]
"""               
    "-v",  
    "-###",  
    "--help[=class[,...]]",
    "  --target-help",  
    "--version", 
    "-wrapper @file",  
    "-fplugin=file", 
    "-fplugin-arg-name=arg",  
    "-fdump-ada-spec[-slim]", 
    "-fdump-go-spec=file"
    
""" 
